package com.socialuni.sdk.utils.model.DO;

import com.socialuni.sdk.constant.status.UserStatus;
import com.socialuni.sdk.model.DO.user.UserDO;
import com.socialuni.sdk.constant.GenderTypeNumEnum;
import com.socialuni.sdk.api.model.RO.user.base.SocialUserRO;
import com.socialuni.sdk.model.ProviderLoginQO;

import java.util.Date;

public class CommonUserDOUtil {
    public static UserDO providerUserLoginQOToDO(ProviderLoginQO userDTO) {
        UserDO user = new UserDO();
        user.setNickname(userDTO.getNickName());
        user.setAvatar(userDTO.getAvatarUrl());

        GenderTypeNumEnum genderTypeNumEnum = GenderTypeNumEnum.getEnumByValue(userDTO.getGender());
        /*if (genderTypeNumEnum != null) {
            user.setGender(genderTypeNumEnum.getName());
        }*/
        user.setBirthday(userDTO.getBirthday());
        user.setCity(userDTO.getCity());

        Date curData = new Date();
        user.setCreateTime(curData);
        user.setUpdateTime(curData);
//        user.setProvider(userDTO.getProvider());
//        user.setPlatform(userDTO.getPlatform());
//
//        user.setType(UserType.personal);
        user.setStatus(UserStatus.enable);
        //未来可以考虑直接手机号也授权
        return user;
    }


    public static UserDO userOAuthROToDO(SocialUserRO userDTO) {
        UserDO user = new UserDO();
        user.setNickname(userDTO.getNickname());
        user.setAvatar(userDTO.getAvatar());
//        user.setGender(userDTO.getGender());
        user.setAge(userDTO.getAge());
        user.setCity(userDTO.getCity());
        user.setStatus(UserStatus.enable);

        Date curData = new Date();
        user.setCreateTime(curData);
        user.setUpdateTime(curData);
//        user.setType(UserType.personal);
        //未来可以考虑直接手机号也授权
        return user;
    }



    /*public static UserDO ProviderLoginROToDO(ProviderLoginQO userDTO) {
        UserDO user = new UserDO();
        user.setNickname(userDTO.getNickname());
        user.setAvatar(userDTO.getAvatar());
        user.setGender(userDTO.getGender());
        user.setAge(userDTO.getAge());
        //根据age生成birthday


        user.setCity(userDTO.getCity());
        user.setStatus(UserStatus.enable);

        Date curData = new Date();
        user.setCreateTime(curData);
        user.setUpdateTime(curData);
        user.setType(UserType.personal);
        //未来可以考虑直接手机号也授权
        return user;
    }*/
}